package cn.hh.order.controller;


import cn.hh.basic.util.AjaxResult;
import cn.hh.basic.util.LoginContext;
import cn.hh.order.service.IAdoptOrderService;
import cn.hh.user.domain.LoginInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/adopt")
public class AdoptOrderController {

    @Autowired
    private IAdoptOrderService adoptOrderService;

    /*点击立即下单生成订单*/
    @PostMapping("/submit")
    public AjaxResult submit(@RequestBody Map<String ,Object> map, HttpServletRequest res){
        System.out.println("接收到的数据"+map);
        LoginInfo logininfo = LoginContext.getLogininfo(res);
        String order = adoptOrderService.submit(map,logininfo.getId());
        return AjaxResult.me().setResultObj(order);
    }
}
